package com.wwj.study.spring.demo.controller;


import com.wwj.study.spring.demo.service.ITestCustomNameService;
import com.wwj.study.spring.demo.service.ITestService;
import com.wwj.study.spring.formework.annotion.WAutowired;
import com.wwj.study.spring.formework.annotion.WController;
import com.wwj.study.spring.formework.annotion.WRequestMapping;
import com.wwj.study.spring.formework.annotion.WRequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by lenovo on 2018/10/30.
 */


@WController
@WRequestMapping(value = "test")
public class TestController {

    @WAutowired
    private ITestService testService;


    @WAutowired
    private ITestCustomNameService testCustomNameService;


    @WRequestMapping(value = "/add.jhtml")
    public void add(@WRequestParam(value = "id") Integer id, HttpServletRequest request, HttpServletResponse response) {
        String result = testService.addService(id);
        System.out.println(result);
        try {
            response.getWriter().write(result);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    @WRequestMapping(value = "/update.jhtml")
    public void update(@WRequestParam(value = "name") String name,  HttpServletRequest request, HttpServletResponse response) {

        System.out.println(name);
        try {
            response.getWriter().write("update:"+name);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
